Fix possible crash in header bar
authorBastien Nocera <hadess@hadess.net>
Fri, 27 Sep 2013 15:06:01 +0000 (17:06 +0200)
committerBastien Nocera <hadess@hadess.net>
Fri, 27 Sep 2013 15:27:31 +0000 (17:27 +0200)
When the header bar's top-level widget is not a GtkWindow,
don't try to get the inexistant "decoration-button-layout"
property.

gtk/gtkheaderbar.c

index 4a0481a4b0562c01eedf5028a7bf7be630107de6..412b27c5953642036ca8ebdfd55334a4697c1a88 100644 (file)
@@ -650,12 +650,15 @@ gtk_header_bar_get_preferred_height_for_width (GtkWidget *widget,
 static gboolean
 close_button_at_end (GtkWidget *widget)
 {
+  GtkWidget *toplevel;
   gchar *layout_desc;
   gboolean at_end;
   gchar *p;
 
-  gtk_widget_style_get (gtk_widget_get_toplevel (widget),
-                        "decoration-button-layout", &layout_desc, NULL);
+  toplevel = gtk_widget_get_toplevel (widget);
+  if (!GTK_IS_WINDOW (toplevel))
+    return TRUE;
+  gtk_widget_style_get (toplevel, "decoration-button-layout", &layout_desc, NULL);
 
   p = strchr (layout_desc, ':');
   if (p && strstr (p, "close"))